package states.gameplay.animations;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Vector2f;

import states.gameplay.Game;
import states.gameplay.Position;

public class GranadorAttackAnimation extends AttackAnimation {

	private Position currentPos;
	private Vector2f direction;
	
	public GranadorAttackAnimation(Position startPos, Position endPos) {
		super(startPos, endPos, 3);

		direction = new Vector2f((endPos.x-startPos.x)*Game.CELL_SIZE, (endPos.y-startPos.y)*Game.CELL_SIZE);
		
		currentPos = new Position(startPos.x*Game.CELL_SIZE+10, startPos.y*Game.CELL_SIZE+24+10);
		
	}

	@Override
	public void update(int delta) {
		currentPos.x += ((float)delta/100.0f) * direction.x;
		currentPos.y += ((float)delta/100.0f) * direction.y;
		
		if(currentPos.x >= endPos.x*Game.CELL_SIZE && currentPos.y >= endPos.y*Game.CELL_SIZE){
			this.setOver(true);
		}	
		
	}

	@Override
	public void render(Graphics g) {
		Color oldColor = g.getColor();
		g.setColor(Color.yellow);
		g.drawRect(currentPos.x, currentPos.y, 5, 5);
		
		g.setColor(oldColor);
	}

}
